package generics;

import java.util.ArrayList;
import java.util.List;

class Apple<T extends Number>
{
	T size;
	public Apple(){
		
	}
	
	public Apple(T size){
		this.size=size;
	}

	public T getSize() {
		return size;
	}

	public void setSize(T size) {
		this.size = size;
	}
	
	public List<String> getApples(){
		List<String> sList = new ArrayList<String>();
		for(int i=1;i<=5;i++){
			sList.add(new Apple<Integer>(i).toString());
		}
		return sList;
	}
	
	public String toString(){
		return "Apple size is "+getSize();
	}
	
}

public class ErasureTest{
	
	public static void main(String[] args) {
		Apple<Integer> a = new Apple<Integer>(6);
		for(String s:a.getApples()){
			System.out.println(s);
		}
		/*
		 * 将a赋给b时会发生泛型擦除，Apple中的所有泛型都会被擦除，包括getApples返回的List<String>变为List
		 * */
		//Apple b =a;
		/*for(String s:b.getApples()){
			System.out.println(s);
		}*/
	}
}